package com.kunbo.cn.service.impl.system;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kunbo.cn.dao.system.BusinessCodeDao;
import com.kunbo.cn.entity.system.BusinessCode;
import com.kunbo.cn.service.system.BusinessCodeService;
@Service
public class BusinessCodeServiceImpl implements BusinessCodeService {
	@Autowired
	private BusinessCodeDao businessCodeDao;


	@Override
	public void update(String type,String date) {
		// TODO Auto-generated method stub
		BusinessCode bc = businessCodeDao.findByTypeAndDate(type, date);
		bc.setNumber(bc.getNumber()+1);
		businessCodeDao.save(bc);

	}

	@Transactional
	@Override
	public void updateNumberAndDate(Integer number, String date) {
		// TODO Auto-generated method stub
		businessCodeDao.updateNumberAndDate(number, date);
	}

	@Override
	public BusinessCode findByTypeAndDate(String type, String date) {
		// TODO Auto-generated method stub
		return businessCodeDao.findByTypeAndDate(type, date);
	}

	@Override
	public List<BusinessCode> findAll() {
		// TODO Auto-generated method stub
		return (List<BusinessCode>) businessCodeDao.findAll();
	}

}
